<template>
	<view class="u-page" v-if="1==col">
		 <view class="u-demo-block"  >
		 	<view class="u-demo-block__content">
				<view class="album" v-for="(msg) in list" >
		 			<view class="album__content" style="border-bottom: 1px solid #eee;">
		 				<u--text
		 						:text="msg.author_name"
		 						:type="primary"
		 						bold
		 						size="17"
		 				></u--text>
		 				<u--text
		 						margin="0 8px 8px 0"
		 						:text="msg.title"
		 				></u--text>
						<image :src="msg.thumbnail_pic_s" style="display: block;width: 80%;" mode="widthFix"></image>
						<u--text
								margin="0 0 8px 0"
								:text="msg.date"
						></u--text>
		 			</view>
		 		</view>
		 	</view>
		 </view>
	</view>
	<view class="u-page" v-else-if="2==col">
	<view class="u-demo-block">
		<view class="u-demo-block__content">
			
			<view class="album" v-for="item in activities" style="border-bottom: 1px solid #eee;">
				<view class="album__avatar" >
					<image
						:src="item.user.userImage"
						mode="widthFix"
						style="width: 41px;"
					></image>
				</view>
				<view class="album__content">
					<u--text
							:text="item.user.username"
							type="primary"
							bold
							size="17"
					></u--text>
					<u--text
							margin="0 0 3px 0"
							:text="item.content"
					></u--text>
					<image :src="item.img" style="display: block;width: 80%;padding: 5px 0px;" mode="widthFix"></image>
					<u--text
							margin="0 0 0 0"
							:text="item.publishTime"
					></u--text>
				</view>
			</view>
			
		</view>
	</view>
	</view>
	
</template>

<script>
	export default {
		props:["col"],
		data(){
			return {
				list:[],
				activities:[]
			}
		},
		methods:{
			getNews(index){
				//如果是选中了新闻的序号，就发送请求获取数据
				if(index==1){
					console.log("获取新闻");
					uni.request({
						url:"http://v.juhe.cn/toutiao/index",
						data:{
							key:"b44550b054133e16928a675514664e81"
						},
						success:(res)=> {
							console.log(res.data.result.data);
							this.list =  res.data.result.data;
						}
					})
				}
			},
			getActions(){
				uni.request({
					url:"http://localhost:6061/activity/",
					method:"GET",
					header:{
						'Authorization':uni.getStorageSync("token")
					},
					success:(res)=> {
						console.log(res.data.data);
						this.activities = res.data.data;
					}
				})
			}
		}
	}
</script>

<style lang="scss">
    .album {
        @include flex;
        align-items: flex-start;


        &__content {
             margin-left: 10px;
			 margin-right: 10px;
             flex: 1;
         }
    }
</style>
